package application;

import com.google.common.base.Predicate;

public class SizeSearchPredicate implements Predicate<Object> {

	private long lowerBound;
	private long upperBound;
	
	public SizeSearchPredicate(long lowerBound, long upperBound) {
		if (lowerBound < upperBound){
			this.lowerBound = lowerBound;
			this.upperBound = upperBound;
		}
		else{
			this.lowerBound = upperBound;
			this.upperBound = lowerBound;
		}
	}
	
	@Override
	public boolean apply(Object arg0) {
		
		if( arg0 instanceof UniqueFileID ){
			long size = ((UniqueFileID) arg0).getSize();
			return size >= lowerBound && size <= upperBound;
		}
		return false;
	}

}
